<template>
  <div id="app">
    <!-- <h3>hello</h3> -->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data () {
    return {

    }
  },
  created () {
    // 本地加载请求静态json文件的形式
    // this.$http.get('/test')
    //   .then(res => {
    //     console.log(res)
    //   })
    this.getUser()
    this.getCartCount()
  },
  methods: {
    getUser () {
      this.$http.get('/api/user')
        .then(res => {
          // console.log(res)
          this.$store.dispatch('saveUserName', res.username)
        })
    },
    getCartCount () {
      this.$http.get('/carts/products/sum')
        .then(res => {
          this.$store.dispatch('saveCartCount', res)
          // console.log(res)
        })
    }
  }

}
</script>

<style>
@import './assets/scss/reset.scss';
@import './assets/scss/base.scss';
/* @import './assets/font/iconfont.css'; */
</style>
